Viewer
All commands related to the control of the PDF Viewer.
activateCursorTool
Select the cursor tool mode.
| Param | Type | Description |
|---|---|---|
| tool | string | pan - select |
Available cursor options:
- pan: Select the pan (draggable hand) tool.
- select: Select the cursor (mouse) tool.
Example
TFTPDFGadget.callCommand({
name: 'activateCursorTool',
args: { tool: 'pan' },
callback: myfunc,
});
openDocument
Open a document into the Viewer.
| Param | Type | Description |
|---|---|---|
| url | string | The source of your PDF document |
Example
TFTPDFGadget.callCommand({
name: 'openDocument',
args: { url: 'url_of_your_pdf.pdf', id: 'an_id' },
callback: myfunc,
});
downloadPDF
Generate a pdf with annotations to download a new PDF.
| Param | Type | Description |
|---|---|---|
| quality | string | The quality of the document |
| saveAs | string | Save the pdf as document, blobUrl, or open the generated file on the viewer |
Available quality options:
- low: 65% quality
- medium: 85% quality
- high: 125% quality
- ultrahigh: 150% quality
Available saveAs options:
- document: Save the pdf as a document
- blobUrl: Save the pdf as a blobUrl
- open: Open the generated file on the viewer
The pdf contains TFTPDF annotations on every page.
Example
TFTPDFGadget.callCommand({
name: 'downloadPDF',
args: { quality: 'high', saveAs: 'saveBrowser', callback: myfunc },
});
getPagesCount ⇒ number
Get the total pages count of the current document.
Example
TFTPDFGadget.callCommand({
name: 'getPagesCount',
callback: myfunc,
});
getCurrentPageIndex ⇒ number
Get the current page index of the current document.
Example
TFTPDFGadget.callCommand({
name: 'getCurrentPageIndex',
callback: myfunc,
});
goToFirstPage ⇒ number
Go to the first page of the PDF.
Example
TFTPDFGadget.callCommand({
name: 'goToFirstPage',
callback: myfunc,
});
goToLastPage ⇒ number
Go to the last page of the PDF.
Example
TFTPDFGadget.callCommand({
name: 'goToLastPage',
callback: myfunc,
});
goToNextPage ⇒ number
Go to the next page of the PDF.
Example
TFTPDFGadget.callCommand({
name: 'goToNextPage',
callback: myfunc,
});
goToPreviousPage ⇒ number
Go to the previous page of the PDF.
Example
TFTPDFGadget.callCommand({
name: 'goToPreviousPage',
callback: myfunc,
});
goToPage ⇒ number
Go to the previous page of the PDF.
| Param | Type | Description |
|---|---|---|
| pageNumber | number | The page number to go to. |
Example
TFTPDFGadget.callCommand({
name: 'goToPage',
args: { pageNumber: 5 },
callback: myfunc,
});
rotateRight
Rotate the PDF to 90° right.
Example
TFTPDFGadget.callCommand({
name: 'rotateRight',
callback: myfunc,
});
rotateLeft
Rotate the PDF to 90° left.
Example
TFTPDFGadget.callCommand({
name: 'rotateLeft',
callback: myfunc,
});
getCurrentDocumentInformation ⇒ JSON
Get informations about the PDF.
Example
TFTPDFGadget.callCommand({
name: 'getCurrentDocumentInformation',
callback: myfunc,
});
getBookmarks ⇒ JSON
Get a list of bookmarks.
Example
TFTPDFGadget.callCommand({
name: 'getBookmarks',
callback: myfunc,
});
Returns
[{"dest":[null,{"name":"XYZ"},null,null,null],"url":null,"title":"Feuilles","color":{"0":0,"1":0,"2":0},"count":9,"bold":false,"italic":false,"items":[{"dest": [{"num":6,"gen":0},{"name":"Fit"}],"url":null,"title":"A10 - ARC-Plan Général / Géomètre","color":{"0":0,"1":0,"2":0},"bold":false,"italic":false,"items":[]}, {"dest":[{"num":8,"gen":0},{"name":"Fit"}],"url":null,"title":"A12 - ARC-Repérage Bus et Postes Distribution","color": {"0":0,"1":0,"2":0},"bold":false,"italic":false,"items":[]}}]
goToBookmark
Go to the bookmark set in parameter.
| Param | Type | Description |
|---|---|---|
| dest | array | Dest is a JSON array who handle the desired bookmark destination |
Example
TFTPDFGadget.callCommand({
name: 'goToBookmark',
args: { dest: [{ num: 9084, gen: 0 }, { name: 'Fit' }] },
callback: myfunc,
});
showOverlay
Show the overlay on the current page.
| Param | Type | Description |
|---|---|---|
| showGrid | bool | Toggle the grid visibility |
Example
TFTPDFGadget.callCommand({
name: 'showOverlay',
args: { showGrid: false },
callback: myfunc,
});
hideOverlay
Hide the overlay on the current page.
Example
TFTPDFGadget.callCommand({
name: 'hideOverlay',
callback: myfunc,
});
setScrollingMode
Select the viewer scrolling mode.
| Param | Type | Description |
|---|---|---|
| mode | string | vertical - horizontal - wrapped |
Available scrolling mode options:
- vertical: Select the vertical scrolling mode.
- horizontal: Select the horizontal scrolling mode.
- wrapped: Select the wrapped scrolling mode.
Example
TFTPDFGadget.callCommand({
name: 'setScrollingMode',
args: { mode: 'vertical' },
callback: myfunc,
});
setDoublePageMode
Select the double page mode.
| Param | Type | Description |
|---|---|---|
| mode | string | none - odd - even |
Available double page mode options:
- none: Disable the double page mode.
- odd: Enable the double page mode, not divisible by two.
- even: Enable the double page mode, divisible by two.
Example
TFTPDFGadget.callCommand({
name: 'setDoublePageMode',
args: { mode: 'none' },
callback: myfunc,
});
takeScreenshot
Take a screenshot of the current page. The command returns an image encoded in Base64 string who's matching the current viewport + TFTLABS's annotations.
Example
TFTPDFGadget.callCommand({
name: 'takeScreenshot',
callback: myfunc,
});
A Base64 image encoded of the current viewport